#! /usr/bin/env python

def con2matrix(seq):	
	"""
	# change consensus sequence into matrix
	"""
	print '\t'.join(['#pos', 'A','C','G','T','nt'])
	seq = seq.upper()
	for pos, letter in enumerate(seq):
		if letter == 'A':
			print  '\t'.join([str(pos+1), '1','0','0','0',letter])
		if letter == 'G':
			print  '\t'.join([str(pos+1),'0','0','1','0',letter])
		if letter == 'C':
			print  '\t'.join([str(pos+1), '0','1','0','0',letter])
		if letter == 'T':
			print  '\t'.join([str(pos+1), '0','0','0','1',letter])
		if letter == 'R':
			print  '\t'.join([str(pos+1), '1','0','1','0',letter])
		if letter == 'W':
			print  '\t'.join([str(pos+1),'1','0','0','1',letter])
		if letter == 'M':
			print  '\t'.join([str(pos+1), '1','1','0','0',letter])
		if letter == 'S':
			print  '\t'.join([str(pos+1), '0','1','1','0',letter])
		if letter == 'Y':
			print  '\t'.join([str(pos+1), '0','1','0','1',letter])
		if letter == 'K':
			print  '\t'.join([str(pos+1), '0','0','1','1',letter])
		if letter == 'H':
			print  '\t'.join([str(pos+1), '1','1','0','1',letter])
		if letter == 'B':
			print  '\t'.join([str(pos+1), '0','1','1','1',letter])
		if letter == 'V':
			print  '\t'.join([str(pos+1), '1','1','1','0',letter])
		if letter == 'D':
			print  '\t'.join([str(pos+1), '1','0','1','1',letter])
		if letter == 'N':
			print  '\t'.join([str(pos+1), '1','1','1','1',letter])

if __name__ == '__main__':
	import sys
	if len(sys.argv) == 1:
		print "usage: python con2matrix.py seq"
	else:
		con2matrix(sys.argv[1])

